<% bookmarkable ||= @bookmarkable %>
<% @bookmark ||= Bookmark.new %>
<% if @bookmark.new_record? && bookmarkable.class != ExternalWork %>
  <p><%=h "Add a new bookmark for".t %> "<%=h bookmarkable.title %>"</p>
<% end %>

<% form_for([bookmarkable, @bookmark], :url => {:controller => 'bookmarks', :action => (action ||= 'create')}) do |f| %>
<dl>
	<% if bookmarkable.class == ExternalWork && bookmarkable.new_record? %>
	<% fields_for 'bookmark[external]', bookmarkable do |ew| %>
	<dt><%= ew.label :url, "URL: ".t %></dt>
	<dd>
		<%= ew.text_field :url %>
		<%= observe_field 'bookmark_external_url', :url => {:controller => 'external_works', :action => 'fetch'}, :with => 'external_url', :on => 'blur' %>
		<%= hidden_field 'fetched', :value => '' %>
	</dd>
	<dt><%= ew.label :author, "Author: ".t %></dt>
		<dd> <%= ew.text_field :author %></dd>
	<dt><%= ew.label :title, "Title: ".t %></dt>
		<dd> <%= ew.text_field :title %> </dd>
	<dt>
	<%= ew.label :summary, "Author's Summary".t %>
	<%=h "(please copy and paste from original work)".t %></dt>
		<dd> <%= ew.text_area :summary %> </dd>
	<% end %>
	<% end %>
	<dt><%= f.label :notes, "Your Notes".t %></dt>
		<dd><%= f.text_area :notes %></dd>
	<dt><%= f.label :tag_string, "Your Tags".t %></dt>
		<dd><%= text_field_tag 'tag_string', @tag_string %></dd>
</dl>
<p> <%= f.check_box :private %> <%= f.label :private, "Private bookmark?".t %> </p>
<p><%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.hidden_field :bookmarkable_id, :value => bookmarkable.id %>
<%= f.hidden_field :bookmarkable_type, :value => bookmarkable.class.to_s %></p>
<p class="submit"><%= f.submit(button_name ||= "Create".t) %></p>
<% end %>
